// packageC/components/o2o-appoinment/o2o-appoinment.js
const app = getApp();
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    store_reserve_info: {
      type: Object,
      value: {}
    },
    store_id: {
      type: null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    show: false,
    mobile: ""
  },
  pageLifetimes: {},
  /**
   * 组件的方法列表
   */
  methods: {
    closePopup() {
      this.setData({
        show: false
      })
    },
    tapGet() {
      this.setData({
        show: true
      })
    },
    callPhone() {
      wx.makePhoneCall({
        phoneNumber: this.data.store_reserve_info.store_mobile,
      })
    },
    toservice(e) {
      let {
        item
      } = e.currentTarget.dataset;
      if (!item.min_service) return app.tips('未设置客服链接');
      wx.navigateTo({
        url: item.min_service,
        fail:(res)=>{
          app.tips(res.errMsg)
        }
      })
    },
    async tapAppoinment() {
      let json = {
        form: {
          store_id: this.data.store_id,
          mobile: this.data.store_reserve_info.member_mobile ? this.data.store_reserve_info.member_mobile : this.data.mobile
        }
      }
      let {
        data
      } = await app._postNetWork({
        url: app.getNetAddresss("plugin.store-cashier.frontend.store.store.store-reserve-info"),
        data: json
      })
      if(data.result){
        this.triggerEvent('update')
      }
      app.tips(data.msg)
    }
  }
})